package com.chiasma.studioadmin.client.ui.studentrecord;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.VerticalSplitPanel;
import com.google.gwt.user.datepicker.client.DatePicker;


public class StudentRecord extends Composite{

	private VerticalPanel upperStudentRecordPanel = new VerticalPanel();
	private VerticalPanel detailStudentRecordPanel = new VerticalPanel();
	
	
	public StudentRecord(){
		
		//Setting up user list
		VerticalPanel menuList = new VerticalPanel();
		menuList.setSize("400px", "100px");
		
		Button createStudentButton = new Button("Create New Student Record", new ClickHandler(){
			public void onClick(ClickEvent event){
				createNewStudentProfile().show();
			}	
		});
		menuList.add(createStudentButton);
		
		
		//Setting up the upperStudentRecordPanel
		upperStudentRecordPanel.setSize("400px", "200px");
//		upperStudentRecordPanel.setStyleName("defaultDiv");
		upperStudentRecordPanel.add(menuList);
	
		//Setting up the detailStudentRecordPanel
		detailStudentRecordPanel.setSize("400px", "200px");
//		detailStudentRecordPanel.setStyleName("defaultDiv");
		detailStudentRecordPanel.add(new HTML("Detailed Student Information"));
		
		initWidget(upperStudentRecordPanel);
		
	}
	
	private DialogBox createNewStudentProfile(){
		
		final DialogBox newStudentProfile = new DialogBox();
		FlexTable studentInfoTable = new FlexTable();
		
		
		studentInfoTable.setHTML(0, 0, "Name (Eng)");
		studentInfoTable.setHTML(1, 0, "Name (Chi)");
		studentInfoTable.setHTML(2, 0, "Gender ");
		studentInfoTable.setHTML(3, 0, "Birthday ");
		
		TextBox studentNameInEng = new TextBox();
		TextBox studentNameInChi = new TextBox();
		studentInfoTable.setWidget(0, 1, studentNameInEng);
		studentInfoTable.setWidget(1, 1, studentNameInChi);
		
		RadioButton genderPickBoy = new RadioButton("gender", "Boy");
		RadioButton genderPickGirl = new RadioButton("gender", "Girl");
		FlowPanel genderPanel = new FlowPanel();
		genderPanel.add(genderPickBoy);
		genderPanel.add(genderPickGirl);
		studentInfoTable.setWidget(2,1, genderPanel);
		
		final DatePicker birthdayDatePicker = new DatePicker();
		birthdayDatePicker.setVisible(false);
		TextBox birthdayText = new TextBox();
		studentInfoTable.setWidget(3,1,birthdayText);
		studentInfoTable.setWidget(3,2,birthdayDatePicker);
		birthdayText.addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {
				birthdayDatePicker.setVisible(true);
				
			}
		});
			
		
		
		Button submitButton = new Button("Save Record", new ClickHandler(){
			public void onClick(ClickEvent event){
				
			}	
		});
		
		Button closeButton = new Button("Close", new ClickHandler(){

			public void onClick(ClickEvent event) {
				newStudentProfile.hide();
				
			}
			
		});
		
		studentInfoTable.setWidget(4, 0, submitButton);
		studentInfoTable.setWidget(4, 1, closeButton);
		newStudentProfile.add(studentInfoTable);
		newStudentProfile.setText("Create New Student Record");
		
		newStudentProfile.center();
		return newStudentProfile;
	}
	
	
	public VerticalPanel getUpperStudentRecordPanel() {
		return upperStudentRecordPanel;
	}

	public void setUpperStudentRecordPanel(VerticalPanel upperStudentRecordPanel) {
		this.upperStudentRecordPanel = upperStudentRecordPanel;
	}

	public VerticalPanel getDetailStudentRecordPanel() {
		return detailStudentRecordPanel;
	}

	public void setDetailStudentRecordPanel(VerticalPanel detailStudentRecordPanel) {
		this.detailStudentRecordPanel = detailStudentRecordPanel;
	}	
	
	
}

